package probability;

import basics.DenseVector;
import basics.Vector;

public class LogisticFunction extends ProbabilityDistribution {

	private Vector _theta;

	public LogisticFunction(int n) {
		_theta = new DenseVector(n);
		_theta.set(01. / (1. * n));
	}

	public double expThetaX(Vector x) {
		return Math.exp(x.timesEqual(_theta).get(0)); // + _theta.get(_theta.length() - 1);
	}

	public void updateParam(Vector val) {
		this._theta.add(val);
	}

	@Override
	public double measure(Vector x) {
		double d = expThetaX(x);
		return d / (1. + d);
	}

	@Override
	protected ProbabilityDistribution newInstance() {
		return new LogisticFunction(_theta.length());
	}

	@Override
	public ProbabilityDistribution times(ProbabilityDistribution distribution) {
		// TODO Auto-generated method stub
		return null;
	}

}
